<?php

class DailymotionMedia
{
	public static
		$user_id	= '4d473a7294a6f66ccd000012',
		$api_key	= '1d2433e03fbb64d3180309b73ba49d94ab4d3bf1',
		$skin_id	= '';
	
	public static function create(Medias $oMedia)
	{
		$sFile = getenv('DOCUMENT_ROOT') . '/upload/movie/'. $oMedia->src;
		
		$cloudkey = new CloudKey($user_id, $api_key);

		# Upload a video
		$res = $cloudkey->file->upload_file($sFile);
		print_r($res);

		# The url of the uploaded video 
		$oMedia->dailymotion_id = $res->url;
	}
	
	
	public static function get_embed_url($sID)
	{
		$oCloud = new CloudKey(self::$user_id, self::$api_key);
		return $oCloud->media->get_embed_url(array('id' => $sID, 'skin' => 'prod'));
	}
	
	public static function constructIframe($sID, $type = 'prod')
	{
		$aType = array(
					'prod' => array('width' => 848, 'height' => 480)
			);
		return '<iframe width="'.$aType[$type]['width'].'" height="'.$aType[$type]['width'].'" frameborder="0" scrolling="no" 
		src="http://api.dmcloud.net/embed/'. self::$user_id .'/'. $sID .'?auth="></iframe>';
	}
}

?>